#search.py
import os
import sys

def search(path, word):
    for filename in os.listdir(path):
        fp = os.path.join(path, filename)
        if os.path.isfile(fp) and word in filename:
            try:
                os.remove(fp)
                print fp
                pass
            except Exception as e:
                print e
                pass
            
        elif os.path.isdir(fp):
            search(fp, word)



if __name__ == "__main__":
    searchFileDir = ['/Users/alex/Library',
    '/Users/alex/Library/Application Support',
    '/Users/alex/Library/Application Support/CrashReporter',
    '/Users/alex/Library/Caches',
    '/Users/alex/Library/Containers',
    '/Users/alex/Library/LaunchAgents',
    '/Users/alex/Library/Preferences',
    '/Users/alex/Library/PreferencePanes',
    '/Library',
    '/Library/Application Support',
    '/Library/Extensions',
    '/Library/LaunchAgents',
    '/Library/LaunchDaemons',
    '/Library/PreferencePanes',
    '/Library/Preferences']
    for onedir in searchFileDir:
        search(onedir, sys.argv[1])
        pass
    